import { fromJS } from 'immutable'
import { actionTypes } from './index'

const defaultState = fromJS({
    imgShow: false,
    backTopShow: false,
    topicList:[],
    arcList : [],
    currArcPage : 1,
    recommondList: [],
    writerList: []

})
export default (state = defaultState,action)=>{
    switch (action.type) {
        case actionTypes.CHANGE_IMG_SHOW:
            return state.set('imgShow',action.value)
        case actionTypes.INIT_HOME_DATA:
            return state.merge({
                topicList: action.data.get('topicList'),
                arcList: action.data.get('arcList'),
                recommondList: action.data.get('recommendList'),
                writerList: action.data.get('writerList')
            })
        case actionTypes.ADD_MORE_ARC:
            return state.merge({
                arcList : state.get('arcList').concat(action.list),
                currArcPage: action.nextPage
            })
        case actionTypes.CHANGE_BACK_TOP_SHOW:
            return state.set('backTopShow',action.status)
        default:
            return state
    }

}
